package main

import (
	"fmt"
	"strconv"
	"strings"
)

var str string = "xhanfhjamngkamd魏正想"

// 常见的系统函数
func main() {
	strs := []rune(str)
	for i := 0; i < len(strs); i++ {
		fmt.Printf("%c\n", strs[i])
	}
	var nnn string = "234"
	result, _ := strconv.ParseInt(nnn, 10, 16)
	fmt.Println(result)
	result1, _ := strconv.Atoi(nnn)
	fmt.Println(result1)
	result2 := strconv.Itoa(123)
	fmt.Printf("%T\n", result2)
	fmt.Println(result2)
	//判断go是否在golang字符串中
	flag := strings.Contains("golang", "go")
	fmt.Println(flag)
	//判断字符串中有多少个指定字符
	counts := strings.Count("gogogogogogogogo", "go")
	fmt.Println(counts)

	//不区分大小写比较字符串
	flag1 := strings.EqualFold("golang", "GOLANG")
	fmt.Println(flag1)

	//找到字符串中给定子串第一次出现的索引值
	index := strings.Index("sndjdngjcuengicneng", "qi")
	fmt.Println(index)

	//字符串的替换
	result3 := strings.Replace("goadnjavagogo", "go", "golang", 2)
	result5 := strings.Replace("goadnjavagogo", "go", "golang", -1)
	fmt.Println("字符串的替换")
	fmt.Println(result3)
	fmt.Println(result5)

	//字符串的分割
	result4 := strings.SplitAfter("gog-ogog-ogogogsuejf-idmg", "-")
	fmt.Printf("字符串分割后的数据类型%T", result4)
	fmt.Println()
	fmt.Println(result4)

	//字符串大小写字母转换
	upper := strings.ToUpper("lulu")
	fmt.Println(upper)
	lower := strings.ToLower("LULU")
	fmt.Println(lower)

	//去掉字符串两边空格
	space := strings.TrimSpace("   WeiZhengXiang  ")
	fmt.Println(space)

	//将字符串两边指定的字符去掉
	trim := strings.Trim("!wzx!-", "!")
	fmt.Println(trim)

	//指定字符串左右边指定字符去掉
	left := strings.TrimLeft("!sndjgn!", "!")
	right := strings.TrimRight("!sndjgn!", "!")
	fmt.Println(left)
	fmt.Println(right)

	//判断字符串是否以指定的字符开头
	prefix := strings.HasPrefix("https://www.bilibili.com/video/"+
		"BV1ng41147AT/?p=70&spm_id_from=333.1007.top_right_"+
		"bar_window_history.content.click&vd_"+
		"source=546576a6f524d3e58d9b93d26e97c920", "https")
	fmt.Println("判断字符串是否以指定的子串开头", prefix)

}
